package lesson4;

public class Driver {
    private String name;
    private int age;

    private Car car;

    public Driver() {
    }

    public Driver(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Driver(String name, int age, Car car) {
        this.name = name;
        this.age = age;
        this.car = car;
    }

    /**
     * 拷贝构造方法
     * @param driver
     */
    public Driver(Driver driver){
        this.name = driver.name;
        this.age = driver.age;
        //this.car = driver.car;
        this.car = new Car(driver.car);

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    public void printInfo(){
        System.out.println("name:"+name+"   age:"+age);
    }
}
